var employees = [
  {
    key: '1',
    name: 'John',
    firstName: 'John',
    lastName: 'Brown',
    age: 32,
    address: 'New York No. 1 Lake Park',
    tags: ['nice', 'developer'],
  },
  {
    key: '2',
    name: 'Jim',
    firstName: 'Jim',
    lastName: 'Green',
    age: 42,
    address: 'London No. 1 Lake Park',
    tags: ['loser'],
  },
  {
    key: '3',
    name: 'Joe',
    firstName: 'Joe',
    lastName: 'Black',
    age: 32,
    address: 'Sidney No. 1 Lake Park',
    tags: ['cool', 'teacher'],
  },
];

export default {
  'GET /api/employees': (_, response) => {
    response.send(employees);
  },

  'GET /api/selectById': ({ query }, response) => {
    var arr = [];
    employees.map((emp) => {
      if (emp.key == query.key) {
        arr.push(emp);
      }
    });
    response.send(arr);
  },

  'GET /api/delEmployee': ({ query }, response) => {
    var arr = [];
    employees.map((emp) => {
      if (emp.key != query.key) {
        arr.push(emp);
      }
    });
    employees = arr;
    response.send(employees);
  },

  'Post /api/AddEmployee': ({ body }, response) => {
    employees = employees.concat([body.user]);
    response.send(employees);
  },
};
